package cn.snmp.mutual.org.opennms.protocols.snmp;

public class SnmpOpaque extends SnmpOctetString {
    static final long serialVersionUID = -6031084829130590165L;
    public static final byte ASNTYPE = 68;

    public SnmpOpaque() {
    }

    public SnmpOpaque(final byte[] data) {
        super(data);
    }

    public SnmpOpaque(final SnmpOpaque second) {
        super(second);
    }

    public SnmpOpaque(final SnmpOctetString second) {
        super(second);
    }

    @Override
    public byte typeId() {
        return 68;
    }

    @Override
    public SnmpSyntax duplicate() {
        return new SnmpOpaque(this);
    }

    @Override
    public Object clone() {
        return new SnmpOpaque(this);
    }

    @Override
    public String toString() {
        final byte[] data = this.getString();
        final StringBuffer b = new StringBuffer();
        for (int i = 0; i < data.length; ++i) {
            final int x = data[i] & 0xFF;
            if (x < 16) {
                b.append('0');
            }
            b.append(Integer.toString(x, 16).toUpperCase());
            if (i < data.length) {
                b.append(' ');
            }
        }
        return b.toString();
    }
}
